package org.zs;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DruidDemoIoc {
    private DruidDataSource dataSource;
    public void setDataSource(DruidDataSource dataSource) {
        this.dataSource = dataSource;
    }

    public void query() throws Exception {
        DruidPooledConnection connection = dataSource.getConnection();
        String sql = "select * from sys_user;";
        PreparedStatement preparedStatement = null;
        preparedStatement = connection.prepareStatement(sql);
//        preparedStatement.setObject(1, "1");
        preparedStatement.executeQuery();

        preparedStatement.close();
        connection.close();
    }
}

